import {
  Inject,
  Controller,
  Post,
  Put,
  Get,
  Param,
  Body,
  Queries
} from "@midwayjs/core";
import { Context } from "@midwayjs/koa";
import { Utils } from "../utils/index";
import { FeedService } from "../service/feed.service";
import { FeedCreateDto, FeedPageQueryDto } from "../dto/feed.dto";

@Controller()
export class FeedController {
  @Inject()
  ctx: Context;

  @Inject()
  feedService: FeedService;

  @Inject()
  utils: Utils;

  @Post("/common-api/feed", { summary: "添加反馈" })
  async add_feed(@Body() dto: FeedCreateDto) {
    const result = await this.feedService.add_feed(dto);
    return this.utils.response.success({
      ...result
    });
  }

  @Put("/auth-api/feed/resolve/:feedId", { summary: "更新反馈" })
  async resolve_feed(
    @Param("feedId") feedId: string,
    @Body("resolveSchema") resolveSchema: string
  ) {
    const result = await this.feedService.resolve_feed(feedId, resolveSchema);
    return this.utils.response.success({
      ...result
    });
  }

  @Get("/auth-api/feed/page", { summary: "获取反馈列表" })
  async get_feed_page_list(@Queries() dto: FeedPageQueryDto) {
    const result = await this.feedService.get_feed_page_list(dto);
    return this.utils.response.success({
      ...result
    });
  }
}
